	//dnn controls are named funky so get the prefix of them
	//var m_sNS = document.ClientID + '_';
	
	//PadDigits padds N a total of totaldigits to the left
    function PadDigits(n, totalDigits) 
    { 
        n = n.toString(); 
        var pd = ''; 
        if (totalDigits > n.length) 
        { 
            for (i=0; i < (totalDigits-n.length); i++) 
            { 
                pd += '0'; 
            } 
        } 
        return pd + n.toString(); 
    } 	
	
	function ChangePick(game_name,team_name, m_sNS) 
	{
		//find out what game we are
		var game_id = game_name.substring(game_name.length-3);
		
		//see if the game is an odd game or even game to figure out opponent
		game_id = game_id - 0;
		if (game_id%2==0)
		{
			var opponent_id = game_id - 1;
		}
		else
		{
			var opponent_id = game_id + 1;
		}
		
		//get the opponent
		opponent_id = PadDigits(opponent_id,3)
		var opponent_name = dnn.dom.getById(m_sNS + 'id' + opponent_id).value;

		//do some math
		var a = Math.round(game_id / 2); //used for writing pick to db
		var b = Math.round(game_id / 2) + 64; // used for changing correct pick onscreen
		var c = Math.ceil(game_id / 4) + 96;
		var d = Math.ceil(game_id / 8) + 112;
		var e = Math.ceil(game_id / 16) + 120;
		var f = Math.ceil(game_id / 32) + 124;
		var g = Math.ceil(game_id / 64) + 126;
		
		//set the chosen winner
		//alert(m_sNS + 'id' + PadDigits(b,3) + '***' + m_sNS + 'ih' + PadDigits(b,3));
		dnn.dom.getById(m_sNS + 'id' + PadDigits(b,3)).value = team_name;
		dnn.dom.getById(m_sNS + 'ih' + PadDigits(b,3)).value = team_name;
		
		//evaluate surrounding picks to set any downstream picks
		if (c < 128)
		{
			var ahead2 = dnn.dom.getById(m_sNS + 'id' + PadDigits(c,3)).value;
			if (ahead2 == opponent_name)
			{
				if (ahead2.length > 0)
				{
					dnn.dom.getById(m_sNS + 'id' + PadDigits(c,3)).value = team_name;
					dnn.dom.getById(m_sNS + 'ih' + PadDigits(c,3)).value = team_name;		
				}
			}
		}
		
		if (d < 128)
		{
			var ahead3 = dnn.dom.getById(m_sNS + 'id' + PadDigits(d,3)).value;
			if (ahead3 == opponent_name)
			{
				if (ahead3.length > 0)
				{
					dnn.dom.getById(m_sNS + 'id' + PadDigits(d,3)).value = team_name;
					dnn.dom.getById(m_sNS + 'ih' + PadDigits(d,3)).value = team_name;		
				}
			}
		}			

		if (e < 128)
		{
			var ahead4 = dnn.dom.getById(m_sNS + 'id' + PadDigits(e,3)).value;
			if (ahead4 == opponent_name)
			{
				if (ahead4.length > 0)
				{
					dnn.dom.getById(m_sNS + 'id' + PadDigits(e,3)).value = team_name;
					dnn.dom.getById(m_sNS + 'ih' + PadDigits(e,3)).value = team_name;	
				}
			}
		}
		
		if (f < 128)
		{
			var ahead5 = dnn.dom.getById(m_sNS + 'id' + PadDigits(f,3)).value;
			if (ahead5 == opponent_name)
			{
				if (ahead5.length > 0)
				{
					dnn.dom.getById(m_sNS + 'id' + PadDigits(f,3)).value = team_name;
					dnn.dom.getById(m_sNS + 'ih' + PadDigits(f,3)).value = team_name;
				}
			}
		}			
		
		if (g < 128)
		{
			var ahead6 = dnn.dom.getById(m_sNS + 'id' + PadDigits(g,3)).value;
			if (ahead6 == opponent_name)
			{
				if (ahead6.length > 0)
				{
					dnn.dom.getById(m_sNS + 'id' + PadDigits(g,3)).value = team_name;
					dnn.dom.getById(m_sNS + 'ih' + PadDigits(g,3)).value = team_name;
				}
			}
		}			
		
	}
